@extends('admin::layouts.master')
@section('content')
    <div class="col-lg-12">
        <div class="card card-table">
            <div class="card-header">标签管理
                <button class="btn btn-primary ml-2">标签列表</button>
                <button class="btn btn-primary" data-toggle="modal" data-target="#add">添加标签</button>
                @component('components.modal',['title' => '添加标签','url' => '/shop/tag','id'=>'add'])
                    <div class="form-group">
                        <label>标签名称</label>
                        <input type="text" required placeholder="请输入标签名称..." name="name" class="form-control">
                    </div>
                @endcomponent
            </div>
            <div class="card-body">
                <table class="table">
                    <thead>
                    <tr>
                        <th>标签编号</th>
                        <th>标签名称</th>
                        {{--<th>所属分类</th>--}}
                        <th>创建时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($tags as $tag)
                        <tr>
                            <td>{{$tag['id']}}</td>
                            <td>{!! $tag['name'] !!}</td>
                            <td>{{$tag['created_at']}}</td>
                            <td>
                                <div class="btn-group" role="group" aria-label="Basic example">
                                    <button data-toggle="modal" data-target="#tagedit{{$tag['id']}}" type="button" class="btn btn-success">编辑</button>
                                    @component('components.modal',['title' => '编辑标签','url' => '/shop/tag/'.$tag['id'],'id'=>'tagedit'.$tag['id'],'method'=>'PATCH'])
                                        <div class="form-group">
                                            <label>分类名称</label>
                                            <input type="text"  value="{{$tag['name']}}" name="name" class="form-control">
                                        </div>
                                    @endcomponent
                                    <form action="{{route('tag.destroy',$tag['id'])}}" method="post">
                                        @csrf
                                        @method('DELETE')
                                        <button type="submit" class="btn btn-danger">删除</button>
                                    </form>
                                </div>
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>

            </div>

        </div>
    </div>
@endsection
